/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.hs.gs;

import com.hs.gs.domain.EvaluationItem;
import java.util.List;
import javax.swing.event.TableModelListener;
import javax.swing.table.TableModel;

/**
 *
 * @author johnny
 */
public class EvaluationTableModel implements TableModel {

    private List<EvaluationItem> items;
    public EvaluationTableModel(List<EvaluationItem> items) {
        this.items = items;
    }
    public int getRowCount() {
        if(items == null)
            return 0;
        else 
            return items.size();
    }

    public int getColumnCount() {
        return 3;
    }

    public String getColumnName(int columnIndex) {
        String[] column = new String [] {
            "内容", "标准设置", "扣分"
        };
        return column[columnIndex];
    }

    public Class<?> getColumnClass(int columnIndex) {
        return String.class;
    }

    public boolean isCellEditable(int rowIndex, int columnIndex) {
        if(columnIndex == 2) 
            return true;
        return false;
    }

    public Object getValueAt(int rowIndex, int columnIndex) {
        if(rowIndex < items.size()) {
            EvaluationItem item = items.get(rowIndex);
            if(columnIndex == 0) {
                return item.getTitle();
            }
            if(columnIndex == 1) {
                return item.getScore().toString();
            }
        }
        return "";
    }

    public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
        
    }

    public void addTableModelListener(TableModelListener l) {
        
    }

    public void removeTableModelListener(TableModelListener l) {
        
    }
    
}
